package Annotations;

import Annotations.WithoutDoubles;
import bean.Kreditgeber;
import java.util.List;
import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;


public class WithoutDoublesValidator implements ConstraintValidator<WithoutDoubles, List<Kreditgeber>>
{
    private boolean doubles;

    @Override
    public void initialize(WithoutDoubles a) {
        
    }

    @Override
    public boolean isValid(List<Kreditgeber> t, ConstraintValidatorContext cvc) {
        int position = t.size()-1;
        String name  = t.get(position).getName();
        
        for(int i=0; i<(t.size()-1); i++){
            if(t.get(i).getName().equals(name)){
                return false;
            }
        }
        return true;
    }


}